﻿// MIT License Copyright 2014 (c) David Melendez. All rights reserved. See License.txt in the project root for license information.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ElCamino.AspNet.Identity.AzureTable.Model;
using System.Resources;

namespace ElCamino.AspNet.Identity.AzureTable.Tests.ModelTests
{
    [TestClass]
    public class IdentityCloudContextTests
    {
        [TestMethod]
        [TestCategory("Identity.Azure.Model")]
        public void IdentityCloudContextCtors()
        {
            var ic = new IdentityCloudContext();
            Assert.IsNotNull(ic, "New IdentityCloudContext is null");

            string strInvalidConnectionStringKey = Guid.NewGuid().ToString();

            try
            {
                ic = new IdentityCloudContext(strInvalidConnectionStringKey);
            }
            catch (ArgumentNullException) { }

            try
            {
                ic = new IdentityCloudContext(string.Empty);
            }
            catch (MissingManifestResourceException) {  }

            //----------------------------------------------
            var iucc = new IdentityCloudContext<IdentityUser>();
            Assert.IsNotNull(iucc, "New IdentityCloudContext is null");

            try
            {
                iucc = new IdentityCloudContext<IdentityUser>(strInvalidConnectionStringKey);
            }
            catch (ArgumentException) { }

            try
            {
                iucc = new IdentityCloudContext<IdentityUser>(string.Empty);
            }
            catch (MissingManifestResourceException) { }
            
            //------------------------------------------

            var i2 = new IdentityCloudContext<IdentityUser, IdentityRole, string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>();
            Assert.IsNotNull(i2, "New IdentityCloudContext is null");

            try
            {
                i2 = new IdentityCloudContext<IdentityUser, IdentityRole, string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>(Guid.NewGuid().ToString());
            }
            catch (ArgumentException) { }

            try
            {
                i2 = new IdentityCloudContext<IdentityUser, IdentityRole, string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>(string.Empty);
            }
            catch (MissingManifestResourceException) { }
        }
    }
}
